﻿

using Knlght.Domain;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knight.Models.Entity
{
    /// <summary>
    /// 设置
    /// </summary>
    public class Setting:TEntityBase
    {
        /// <summary>
        /// 键
        /// </summary>       
        public string Key { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        public string Value { get; set; }
        /// <summary>
        /// 设置组
        /// </summary>
        public string Group { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }
    }


    public class SettingMapping : EntityTypeConfiguration<Setting>
    {
        public SettingMapping()
        {
            // 设置表名
            this.ToTable("T" + nameof(Setting));
            //设置主键
            this.HasKey(a => a.Key);
            //不自增
            this.Property(t => t.Key).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            //不更新
            //this.Property(t => t.UpdateTime).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
            // 设置属性的类型和长度
            this.Property(a => a.Key).HasColumnType("NVarchar").HasMaxLength(200);
        }
    }
}
